/*
 * @Author: zzd993
 * @Date: 2023-02-10 22:41:42
 * @LastEditors: zzd993
 * @LastEditTime: 2023-02-10 23:01:47
 * @FilePath: \手写vue2源码\src\vdom\index.js
 * Copyright (c) 2023 by ZZD, All Rights Reserved. 
 */

// h()  _c()
export function createElementVNode(vm, tag, data={}, ...children) {
    if(data == null) { data = {} }
    let key = data.key
    if(key) {
        delete data.key
    }
    return vnode(vm, tag, key, data, children)
}


// _v()
export function createTextVNode(vm, text) {
    return vnode(vm, undefined, undefined, undefined, undefined, text)
}


// 这和ast一样吗？ast做的是语法层面的转化，它描述的是语法本身（可以描述js、css、html）
// 虚拟DOM描述的是dom元素，可以增加一些自定义属性
function vnode(vm, tag, key, data, children, text) {
    return {
        vm, tag, key, data, children, text
        // ....
    }
}